import axios from 'axios';
import conf from '../config/axios';

// 创建axios实例
const service = axios.create(conf);

// request拦截器
service.interceptors.request.use(config => {
    return config;
}, error => {
    // Do something with request error
    console.log(error); // for debug
    Promise.reject(error);
});

// respone拦截器
service.interceptors.response.use(
    response => {
        return response;
    },
    error => {
        console.log('response inter err：' + error); // for debug
        // 最好能回调服务器系统错误
        return Promise.reject(error);
    });

export default service;